package com.yanu.trace.t2s.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yanu.trace.t2s.entity.Enterprise;
import com.yanu.trace.t2s.mapper.EnterpriseMapper;
import com.yanu.trace.t2s.service.EnterpriseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yanu.trace.t2s.util.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whj
 * @since 2021-06-23
 */
@Service
@Transactional
public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper, Enterprise> implements EnterpriseService {
    @Autowired
    EnterpriseMapper enterpriseMapper;
    @Override
    public IPage<Enterprise> selectByPage(Page<Enterprise> page) {
        return enterpriseMapper.selectPageVo(page);//调用mybatisplus内置分页函数返回分页结果
    }

    @Override
    public Enterprise getbyinvite_code(String invite_code) {
        QueryWrapper<Enterprise> wrapper = new QueryWrapper<>();//实例化查询包装器
        return enterpriseMapper.selectOne(wrapper.eq("invite_code",invite_code));//返回邀请码相等的第一个数据
    }
}
